<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>正则表达式</title>
</head>
<body>
    <label>手机号</label>
    <input id="phone"><br>
    <span></span><br>
    <label>相邻重复单词</label>
    <input id="re"><br>
    <span></span><br>
    <button id="btn">提交</button>
<script>
    var phone = document.getElementById("phone"),
        re = document.getElementById("re"),
        btn = document.getElementById("btn"),
        spans = document.getElementsByTagName("span"),
        regexp1 =  /^1[3578]\d{9}$/,
        regexp2 = /\b([a-zA-Z]+)\s+\1\b/;
    btn.onclick = function() {
        if (regexp1.test(phone.value)) {
            spans[0].innerHTML = "true";
        } else {
            spans[0].innerHTML = "false";
        }
        
        if (regexp2.test(re.value)) {
            spans[1].innerHTML = "true";
        } else {
            spans[1].innerHTML = "false";
        }        
    }    
</script>    
</body>    
</html>